export namespace R {
  export function base(url: string, prefix?: string): string
  export function base(api: { url: string }, prefix?: string): string
  export function base(url: string | { url: string }, prefix = '') {
    if (typeof url != 'string') url = url.url
    return `${prefix}${url}`
  }

  type MethodLowerCase = 'get' | 'post' | 'put' | 'delete'
  export function method({ method: _method }: { method: string }): MethodLowerCase {
    return _method.toLowerCase() as any
  }

  export function cbase(prefix: string) {
    return (url: string | { url: string }) => base(url as any, prefix)
  }
}

export default R